import { Ref, ref } from "vue";
export default function useBackTop(): {
  pageRef: Ref;
  isScroll: Ref<boolean>;
  scrollTop: () => void;
  scroll: () => void;
} {
  const pageRef = ref();
  const isScroll = ref<boolean>(false);
  const scrollTop = () => {
    isScroll.value = false;
    pageRef.value.scrollTo(0, 0);
  };
  const scroll = () => {
    const scrollTop = pageRef.value.scrollTop;
    isScroll.value = scrollTop > 100;
  };
  return {
    pageRef,
    isScroll,
    scrollTop,
    scroll,
  };
}
